/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙，邂逅框架梦]
 * 
 * https://zhiqim.org/project/zhiqim_framework/zhiqim_kernel.htm
 *
 * Zhiqim Kernel is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package org.zhiqim.kernel.model.maps;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import org.zhiqim.kernel.xml.XmlTag;

/**
 * 定义在特定场景创建Map<String, Object>时，无需指定泛型
 *
 * @version v1.0.0 @author zouzhigang 2016-11-15 新建与整理
 */
public abstract class MapSO implements MapS, XmlTag
{
    protected String xmlTag;
    protected Map<String, Object> instance;
    
    /***********************************************************/
    //返回Map实例的方法
    /***********************************************************/
    
    /** 设置XML类标识 */
    public void setXmlTag(String xmlTag)
    {
        this.xmlTag = xmlTag;
    }
    
    /** 获取XML类标识 */
    public String getXmlTag()
    {
        return xmlTag;
    }
    
    /**
     * 返回对应的Map实例
     * 
     * @return          Map实例
     */
    public Map<String, Object> instance()
    {
        return instance;
    }
    
    /***********************************************************/
    //增加&修改&删除Map数据
    /***********************************************************/
    
    public MapSO putAll(MapSO m)
    {
        instance.putAll(m.instance());
        return this;
    }
    
    public MapSO putAll(Map<String, Object> m)
    {
        instance.putAll(m);
        return this;
    }
    
    public MapSO put(String key, Object value)
    {
        instance.put(key, value);
        return this;
    }
    
    public MapSO clear()
    {
        instance.clear();
        return this;
    }
    
    /***********************************************************/
    //获取Map的数据
    /***********************************************************/
    
    public Object get(String key)
    {
        return instance.get(key);
    }
    
    public Object remove(String key)
    {
        return instance.remove(key);
    }
    
    public int size()
    {
        return instance.size();
    }
    
    public boolean isEmpty()
    {
        return instance.isEmpty();
    }
    
    public boolean containsKey(String key)
    {
        return instance.containsKey(key);
    }
    
    public boolean containsValue(Object value)
    {
        return instance.containsValue(value);
    }
    
    public Set<String> keySet()
    {
        return instance.keySet();
    }
    
    public Collection<Object> values()
    {
        return instance.values();
    }
    
    public Set<Map.Entry<String, Object>> entrySet()
    {
        return instance.entrySet();
    }
    
    public String toString()
    {
        return instance.toString();
    }
}
